[PATCH v7 6/6] Handle pg_get_triggerdef default args in system_functions.sql

Mark Wong <markwkm@gmail.com>

From: Mark Wong <markwkm@gmail.com>
To:
Date: 2025-12-09T19:51:39Z
Lists: pgsql-hackers
Modernize pg_get_triggerdef to use proargdefaults to handle the optional
pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 14 --------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 707f83d4310..249f4518f62 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -818,20 +818,6 @@ pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn)
  */
 Datum
 pg_get_triggerdef(PG_FUNCTION_ARGS)
-{
-	Oid			trigid = PG_GETARG_OID(0);
-	char	   *res;
-
-	res = pg_get_triggerdef_worker(trigid, false);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_triggerdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			trigid = 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 855529509de..f4df55370e7 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -4003,9 +4003,6 @@
   proname => 'pg_get_partition_constraintdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
   prosrc => 'pg_get_partition_constraintdef' },
-{ oid => '1662', descr => 'trigger description',
-  proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_triggerdef' },
 { oid => '1665', descr => 'name of sequence for a serial column',
   proname => 'pg_get_serial_sequence', provolatile => 's', prorettype => 'text',
   proargtypes => 'text text', prosrc => 'pg_get_serial_sequence' },
@@ -8673,9 +8670,10 @@
   proallargtypes => '{text,text,interval,bool}', proargmodes => '{o,o,o,o}',
   proargnames => '{name,abbrev,utc_offset,is_dst}',
   prosrc => 'pg_timezone_names' },
-{ oid => '2730', descr => 'trigger description with pretty-print option',
+{ oid => '2730', descr => 'trigger description',
   proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid bool', prosrc => 'pg_get_triggerdef_ext' },
+  proargtypes => 'oid bool', proargnames => '{trigger,pretty}',
+  proargdefaults => '{false}', prosrc => 'pg_get_triggerdef' },
 
 # asynchronous notifications
 { oid => '3035',
-- 
2.52.0


--GzYugJnip6WHHvTk--