agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 06/11] enhancing psql for session variables
214+ messages / 3 participants
[nested] [flat]

* [PATCH 06/11] enhancing psql for session variables
@ 2022-04-04 20:40  [email protected] <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: [email protected] @ 2022-04-04 20:40 UTC (permalink / raw)

\dV and tab complete for session variables related commands
---
 src/bin/psql/command.c      |  3 ++
 src/bin/psql/describe.c     | 96 +++++++++++++++++++++++++++++++++++++
 src/bin/psql/describe.h     |  3 ++
 src/bin/psql/help.c         |  1 +
 src/bin/psql/tab-complete.c | 70 ++++++++++++++++++++++-----
 5 files changed, 162 insertions(+), 11 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a141146e70..83738b10f3 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -944,6 +944,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 						break;
 				}
 				break;
+			case 'V':			/* Variables */
+				success = listVariables(pattern, show_verbose);
+				break;
 			case 'x':			/* Extensions */
 				if (show_verbose)
 					success = listExtensionContents(pattern);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index c645d66418..a958853c6d 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -5065,6 +5065,102 @@ error_return:
 	return false;
 }
 
+/*
+ * \dV
+ *
+ * listVariables()
+ */
+bool
+listVariables(const char *pattern, bool verbose)
+{
+	PQExpBufferData buf;
+	PGresult   *res;
+	printQueryOpt myopt = pset.popt;
+	static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false};
+
+	initPQExpBuffer(&buf);
+
+	printfPQExpBuffer(&buf,
+					  "SELECT n.nspname as \"%s\",\n"
+					  "  v.varname as \"%s\",\n"
+					  "  pg_catalog.format_type(v.vartype, v.vartypmod) as \"%s\",\n"
+					  "  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
+					  "   WHERE c.oid = v.varcollation AND bt.oid = v.vartype AND v.varcollation <> bt.typcollation) as \"%s\",\n"
+					  "  NOT v.varisnotnull as \"%s\",\n"
+					  "  NOT v.varisimmutable as \"%s\",\n"
+					  "  pg_catalog.pg_get_expr(v.vardefexpr, 0) as \"%s\",\n"
+					  "  pg_catalog.pg_get_userbyid(v.varowner) as \"%s\",\n"
+					  "  CASE v.vareoxaction\n"
+					  "    WHEN 'd' THEN 'ON COMMIT DROP'\n"
+					  "    WHEN 'r' THEN 'ON TRANSACTION END RESET' END as \"%s\"\n",
+					  gettext_noop("Schema"),
+					  gettext_noop("Name"),
+					  gettext_noop("Type"),
+					  gettext_noop("Collation"),
+					  gettext_noop("Nullable"),
+					  gettext_noop("Mutable"),
+					  gettext_noop("Default"),
+					  gettext_noop("Owner"),
+					  gettext_noop("Transactional end action"));
+
+	if (verbose)
+	{
+		appendPQExpBufferStr(&buf, ",\n  ");
+		printACLColumn(&buf, "v.varacl");
+		appendPQExpBuffer(&buf,
+						  ",\n  pg_catalog.obj_description(v.oid, 'pg_variable') AS \"%s\"",
+						  gettext_noop("Description"));
+	}
+
+	appendPQExpBufferStr(&buf,
+						 "\nFROM pg_catalog.pg_variable v"
+						 "\n     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = v.varnamespace");
+
+	appendPQExpBufferStr(&buf, "\nWHERE true\n");
+	if (!pattern)
+		appendPQExpBufferStr(&buf, "      AND n.nspname <> 'pg_catalog'\n"
+							 "      AND n.nspname <> 'information_schema'\n");
+
+	if (!validateSQLNamePattern(&buf, pattern, true, false,
+								"n.nspname", "v.varname", NULL,
+								"pg_catalog.pg_variable_is_visible(v.oid)",
+								NULL, 3))
+		return false;
+
+	appendPQExpBufferStr(&buf, "ORDER BY 1,2;");
+
+	res = PSQLexec(buf.data);
+	termPQExpBuffer(&buf);
+	if (!res)
+		return false;
+
+	/*
+	 * Most functions in this file are content to print an empty table when
+	 * there are no matching objects.  We intentionally deviate from that
+	 * here, but only in !quiet mode, for historical reasons.
+	 */
+	if (PQntuples(res) == 0 && !pset.quiet)
+	{
+		if (pattern)
+			pg_log_error("Did not find any session variable named \"%s\".",
+						 pattern);
+		else
+			pg_log_error("Did not find any session variables.");
+	}
+	else
+	{
+		myopt.nullPrint = NULL;
+		myopt.title = _("List of variables");
+		myopt.translate_header = true;
+		myopt.translate_columns = translate_columns;
+		myopt.n_translate_columns = lengthof(translate_columns);
+
+		printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
+	}
+
+	PQclear(res);
+	return true;
+}
 
 /*
  * \dFp
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 7872c71f58..6960c738bd 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -146,4 +146,7 @@ extern bool listOpFamilyFunctions(const char *access_method_pattern,
 /* \dl or \lo_list */
 extern bool listLargeObjects(bool verbose);
 
+/* \dV */
+extern bool listVariables(const char *pattern, bool varbose);
+
 #endif							/* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index f8ce1a0706..dcdfb20418 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -286,6 +286,7 @@ slashUsage(unsigned short int pager)
 	HELP0("  \\dT[S+] [PATTERN]      list data types\n");
 	HELP0("  \\du[S+] [PATTERN]      list roles\n");
 	HELP0("  \\dv[S+] [PATTERN]      list views\n");
+	HELP0("  \\dV     [PATTERN]      list variables\n");
 	HELP0("  \\dx[+]  [PATTERN]      list extensions\n");
 	HELP0("  \\dX     [PATTERN]      list extended statistics\n");
 	HELP0("  \\dy[+]  [PATTERN]      list event triggers\n");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 62a39779b9..2780c2239c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -962,6 +962,13 @@ static const SchemaQuery Query_for_trigger_of_table = {
 	.refnamespace = "c1.relnamespace",
 };
 
+static const SchemaQuery Query_for_list_of_variables = {
+	.min_server_version = 150000,
+	.catname = "pg_catalog.pg_variable v",
+	.viscondition = "pg_catalog.pg_variable_is_visible(v.oid)",
+	.namespace = "v.varnamespace",
+	.result = "v.varname",
+};
 
 /*
  * Queries to get lists of names of various kinds of things, possibly
@@ -1219,6 +1226,8 @@ static const pgsql_thing_t words_after_create[] = {
 	{"FOREIGN TABLE", NULL, NULL, NULL},
 	{"FUNCTION", NULL, NULL, Query_for_list_of_functions},
 	{"GROUP", Query_for_list_of_roles},
+	{"IMMUTABLE VARIABLE", NULL, NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER},	/* for CREATE
+																				 * IMMUTABLE VARIABLE ... */
 	{"INDEX", NULL, NULL, &Query_for_list_of_indexes},
 	{"LANGUAGE", Query_for_list_of_languages},
 	{"LARGE OBJECT", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
@@ -1257,6 +1266,7 @@ static const pgsql_thing_t words_after_create[] = {
 																			 * TABLE ... */
 	{"USER", Query_for_list_of_roles, NULL, NULL, Keywords_for_user_thing},
 	{"USER MAPPING FOR", NULL, NULL, NULL},
+	{"VARIABLE", NULL, NULL, &Query_for_list_of_variables},
 	{"VIEW", NULL, NULL, &Query_for_list_of_views},
 	{NULL}						/* end of list */
 };
@@ -1668,7 +1678,8 @@ psql_completion(const char *text, int start, int end)
 		"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
 		"COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE",
 		"DELETE FROM", "DISCARD", "DO", "DROP", "END", "EXECUTE", "EXPLAIN",
-		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LISTEN", "LOAD", "LOCK",
+		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LET",
+		"LISTEN", "LOAD", "LOCK",
 		"MERGE", "MOVE", "NOTIFY", "PREPARE",
 		"REASSIGN", "REFRESH MATERIALIZED VIEW", "REINDEX", "RELEASE",
 		"RESET", "REVOKE", "ROLLBACK",
@@ -1688,7 +1699,7 @@ psql_completion(const char *text, int start, int end)
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\dP", "\\dPi", "\\dPt",
 		"\\drds", "\\dRs", "\\dRp", "\\ds",
-		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy",
+		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy", "\\dV",
 		"\\echo", "\\edit", "\\ef", "\\elif", "\\else", "\\encoding",
 		"\\endif", "\\errverbose", "\\ev",
 		"\\f",
@@ -2129,6 +2140,9 @@ psql_completion(const char *text, int start, int end)
 										  "ALL");
 	else if (Matches("ALTER", "SYSTEM", "SET", MatchAny))
 		COMPLETE_WITH("TO");
+	/* ALTER VARIABLE <name> */
+	else if (Matches("ALTER", "VARIABLE", MatchAny))
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 	/* ALTER VIEW <name> */
 	else if (Matches("ALTER", "VIEW", MatchAny))
 		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME",
@@ -2635,7 +2649,7 @@ psql_completion(const char *text, int start, int end)
 					  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE", "SERVER",
 					  "STATISTICS", "SUBSCRIPTION", "TABLE",
 					  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
-					  "TRIGGER", "TYPE", "VIEW");
+					  "TRIGGER", "TYPE", "VARIABLE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
@@ -3073,7 +3087,7 @@ psql_completion(const char *text, int start, int end)
 /* CREATE TABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
 	else if (TailMatches("CREATE", "TEMP|TEMPORARY"))
-		COMPLETE_WITH("SEQUENCE", "TABLE", "VIEW");
+		COMPLETE_WITH("IMMUTABLE VARIABLE", "SEQUENCE", "TABLE", "VIEW", "VARIABLE");
 	/* Complete "CREATE UNLOGGED" with TABLE or MATVIEW */
 	else if (TailMatches("CREATE", "UNLOGGED"))
 		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW");
@@ -3380,6 +3394,17 @@ psql_completion(const char *text, int start, int end)
 		else if (TailMatches("=", MatchAnyExcept("*)")))
 			COMPLETE_WITH(",", ")");
 	}
+/* CREATE VARIABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
+	/* Complete CREATE VARIABLE <name> with AS */
+	else if (TailMatches("IMMUTABLE"))
+		COMPLETE_WITH("VARIABLE");
+	else if (TailMatches("CREATE", "VARIABLE", MatchAny) ||
+			 TailMatches("TEMP|TEMPORARY", "VARIABLE", MatchAny) ||
+			 TailMatches("IMMUTABLE", "VARIABLE", MatchAny))
+			COMPLETE_WITH("AS");
+	else if (TailMatches("VARIABLE", MatchAny, "AS"))
+			/* Complete CREATE VARIABLE <name> with AS types */
+			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
 
 /* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete CREATE [ OR REPLACE ] VIEW <name> with AS */
@@ -3495,7 +3520,7 @@ psql_completion(const char *text, int start, int end)
 
 /* DISCARD */
 	else if (Matches("DISCARD"))
-		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP");
+		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP", "VARIABLES");
 
 /* DO */
 	else if (Matches("DO"))
@@ -3622,6 +3647,12 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE", MatchAny))
 		COMPLETE_WITH("CASCADE", "RESTRICT");
 
+	/* DROP VARIABLE */
+	else if (Matches("DROP", "VARIABLE"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	else if (Matches("DROP", "VARIABLE", MatchAny))
+		COMPLETE_WITH("CASCADE", "RESTRICT");
+
 /* EXECUTE */
 	else if (Matches("EXECUTE"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
@@ -3738,7 +3769,8 @@ psql_completion(const char *text, int start, int end)
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
 			COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
 						  "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
-						  "EXECUTE", "USAGE", "ALL");
+						  "EXECUTE", "USAGE", "ALL",
+						  "READ", "WRITE");
 		else
 			COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
 									 "GRANT",
@@ -3756,6 +3788,8 @@ psql_completion(const char *text, int start, int end)
 									 "USAGE",
 									 "SET",
 									 "ALTER SYSTEM",
+									 "READ",
+									 "WRITE",
 									 "ALL");
 	}
 
@@ -3797,7 +3831,7 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("GRANT|REVOKE", MatchAny) ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny))
 	{
-		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|ALL"))
+		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|READ|WRITE|ALL"))
 			COMPLETE_WITH("ON");
 		else if (TailMatches("GRANT", MatchAny))
 			COMPLETE_WITH("TO");
@@ -3820,7 +3854,7 @@ psql_completion(const char *text, int start, int end)
 		 * objects supported.
 		 */
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
-			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS");
+			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS", "VARIABLES");
 		else
 			COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_grantables,
 											"ALL FUNCTIONS IN SCHEMA",
@@ -3842,7 +3876,8 @@ psql_completion(const char *text, int start, int end)
 											"SEQUENCE",
 											"TABLE",
 											"TABLESPACE",
-											"TYPE");
+											"TYPE",
+											"VARIABLE");
 	}
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "ALL"))
@@ -3850,7 +3885,8 @@ psql_completion(const char *text, int start, int end)
 					  "PROCEDURES IN SCHEMA",
 					  "ROUTINES IN SCHEMA",
 					  "SEQUENCES IN SCHEMA",
-					  "TABLES IN SCHEMA");
+					  "TABLES IN SCHEMA",
+					  "VARIABLES IN SCHEMA");
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "FOREIGN"))
 		COMPLETE_WITH("DATA WRAPPER", "SERVER");
@@ -3886,6 +3922,8 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
 		else if (TailMatches("TYPE"))
 			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
+		else if (TailMatches("VARIABLE"))
+			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 		else if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny))
 			COMPLETE_WITH("TO");
 		else
@@ -4128,7 +4166,7 @@ psql_completion(const char *text, int start, int end)
 
 /* PREPARE xx AS */
 	else if (Matches("PREPARE", MatchAny, "AS"))
-		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM");
+		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM", "LET");
 
 /*
  * PREPARE TRANSACTION is missing on purpose. It's intended for transaction
@@ -4416,6 +4454,14 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("UPDATE", MatchAny, "SET", MatchAnyExcept("*=")))
 		COMPLETE_WITH("=");
 
+/* LET --- can be inside EXPLAIN, PREPARE etc */
+	/* If prev. word is LET suggest a list of variables */
+	else if (TailMatches("LET"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	/* Complete LET <variable> with "=" */
+	else if (TailMatches("LET", MatchAny))
+		COMPLETE_WITH("=");
+
 /* USER MAPPING */
 	else if (Matches("ALTER|CREATE|DROP", "USER", "MAPPING"))
 		COMPLETE_WITH("FOR");
@@ -4582,6 +4628,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	else if (TailMatchesCS("\\dv*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views);
+	else if (TailMatchesCS("\\dV*"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 	else if (TailMatchesCS("\\dx*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_extensions);
 	else if (TailMatchesCS("\\dX*"))
-- 
2.37.2


--gcms4zhgklsgym3k
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename*0=v20220906-1-0007-possibility-to-dump-session-variables-by-pg_;
	filename*1="dump.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v20220916 08/13] enhancing psql for session variables
@ 2022-04-04 20:40  [email protected] <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: [email protected] @ 2022-04-04 20:40 UTC (permalink / raw)

\dV and tab complete for session variables related commands
---
 src/bin/psql/command.c      |  3 ++
 src/bin/psql/describe.c     | 96 +++++++++++++++++++++++++++++++++++++
 src/bin/psql/describe.h     |  3 ++
 src/bin/psql/help.c         |  1 +
 src/bin/psql/tab-complete.c | 70 ++++++++++++++++++++++-----
 5 files changed, 162 insertions(+), 11 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a141146e70..83738b10f3 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -944,6 +944,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 						break;
 				}
 				break;
+			case 'V':			/* Variables */
+				success = listVariables(pattern, show_verbose);
+				break;
 			case 'x':			/* Extensions */
 				if (show_verbose)
 					success = listExtensionContents(pattern);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index c645d66418..a958853c6d 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -5065,6 +5065,102 @@ error_return:
 	return false;
 }
 
+/*
+ * \dV
+ *
+ * listVariables()
+ */
+bool
+listVariables(const char *pattern, bool verbose)
+{
+	PQExpBufferData buf;
+	PGresult   *res;
+	printQueryOpt myopt = pset.popt;
+	static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false};
+
+	initPQExpBuffer(&buf);
+
+	printfPQExpBuffer(&buf,
+					  "SELECT n.nspname as \"%s\",\n"
+					  "  v.varname as \"%s\",\n"
+					  "  pg_catalog.format_type(v.vartype, v.vartypmod) as \"%s\",\n"
+					  "  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
+					  "   WHERE c.oid = v.varcollation AND bt.oid = v.vartype AND v.varcollation <> bt.typcollation) as \"%s\",\n"
+					  "  NOT v.varisnotnull as \"%s\",\n"
+					  "  NOT v.varisimmutable as \"%s\",\n"
+					  "  pg_catalog.pg_get_expr(v.vardefexpr, 0) as \"%s\",\n"
+					  "  pg_catalog.pg_get_userbyid(v.varowner) as \"%s\",\n"
+					  "  CASE v.vareoxaction\n"
+					  "    WHEN 'd' THEN 'ON COMMIT DROP'\n"
+					  "    WHEN 'r' THEN 'ON TRANSACTION END RESET' END as \"%s\"\n",
+					  gettext_noop("Schema"),
+					  gettext_noop("Name"),
+					  gettext_noop("Type"),
+					  gettext_noop("Collation"),
+					  gettext_noop("Nullable"),
+					  gettext_noop("Mutable"),
+					  gettext_noop("Default"),
+					  gettext_noop("Owner"),
+					  gettext_noop("Transactional end action"));
+
+	if (verbose)
+	{
+		appendPQExpBufferStr(&buf, ",\n  ");
+		printACLColumn(&buf, "v.varacl");
+		appendPQExpBuffer(&buf,
+						  ",\n  pg_catalog.obj_description(v.oid, 'pg_variable') AS \"%s\"",
+						  gettext_noop("Description"));
+	}
+
+	appendPQExpBufferStr(&buf,
+						 "\nFROM pg_catalog.pg_variable v"
+						 "\n     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = v.varnamespace");
+
+	appendPQExpBufferStr(&buf, "\nWHERE true\n");
+	if (!pattern)
+		appendPQExpBufferStr(&buf, "      AND n.nspname <> 'pg_catalog'\n"
+							 "      AND n.nspname <> 'information_schema'\n");
+
+	if (!validateSQLNamePattern(&buf, pattern, true, false,
+								"n.nspname", "v.varname", NULL,
+								"pg_catalog.pg_variable_is_visible(v.oid)",
+								NULL, 3))
+		return false;
+
+	appendPQExpBufferStr(&buf, "ORDER BY 1,2;");
+
+	res = PSQLexec(buf.data);
+	termPQExpBuffer(&buf);
+	if (!res)
+		return false;
+
+	/*
+	 * Most functions in this file are content to print an empty table when
+	 * there are no matching objects.  We intentionally deviate from that
+	 * here, but only in !quiet mode, for historical reasons.
+	 */
+	if (PQntuples(res) == 0 && !pset.quiet)
+	{
+		if (pattern)
+			pg_log_error("Did not find any session variable named \"%s\".",
+						 pattern);
+		else
+			pg_log_error("Did not find any session variables.");
+	}
+	else
+	{
+		myopt.nullPrint = NULL;
+		myopt.title = _("List of variables");
+		myopt.translate_header = true;
+		myopt.translate_columns = translate_columns;
+		myopt.n_translate_columns = lengthof(translate_columns);
+
+		printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
+	}
+
+	PQclear(res);
+	return true;
+}
 
 /*
  * \dFp
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 7872c71f58..6960c738bd 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -146,4 +146,7 @@ extern bool listOpFamilyFunctions(const char *access_method_pattern,
 /* \dl or \lo_list */
 extern bool listLargeObjects(bool verbose);
 
+/* \dV */
+extern bool listVariables(const char *pattern, bool varbose);
+
 #endif							/* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index f8ce1a0706..dcdfb20418 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -286,6 +286,7 @@ slashUsage(unsigned short int pager)
 	HELP0("  \\dT[S+] [PATTERN]      list data types\n");
 	HELP0("  \\du[S+] [PATTERN]      list roles\n");
 	HELP0("  \\dv[S+] [PATTERN]      list views\n");
+	HELP0("  \\dV     [PATTERN]      list variables\n");
 	HELP0("  \\dx[+]  [PATTERN]      list extensions\n");
 	HELP0("  \\dX     [PATTERN]      list extended statistics\n");
 	HELP0("  \\dy[+]  [PATTERN]      list event triggers\n");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index f3465adb85..519c863202 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -962,6 +962,13 @@ static const SchemaQuery Query_for_trigger_of_table = {
 	.refnamespace = "c1.relnamespace",
 };
 
+static const SchemaQuery Query_for_list_of_variables = {
+	.min_server_version = 150000,
+	.catname = "pg_catalog.pg_variable v",
+	.viscondition = "pg_catalog.pg_variable_is_visible(v.oid)",
+	.namespace = "v.varnamespace",
+	.result = "v.varname",
+};
 
 /*
  * Queries to get lists of names of various kinds of things, possibly
@@ -1219,6 +1226,8 @@ static const pgsql_thing_t words_after_create[] = {
 	{"FOREIGN TABLE", NULL, NULL, NULL},
 	{"FUNCTION", NULL, NULL, Query_for_list_of_functions},
 	{"GROUP", Query_for_list_of_roles},
+	{"IMMUTABLE VARIABLE", NULL, NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE IMMUTABLE
+																					 * VARIABLE ... */
 	{"INDEX", NULL, NULL, &Query_for_list_of_indexes},
 	{"LANGUAGE", Query_for_list_of_languages},
 	{"LARGE OBJECT", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
@@ -1257,6 +1266,7 @@ static const pgsql_thing_t words_after_create[] = {
 																			 * TABLE ... */
 	{"USER", Query_for_list_of_roles, NULL, NULL, Keywords_for_user_thing},
 	{"USER MAPPING FOR", NULL, NULL, NULL},
+	{"VARIABLE", NULL, NULL, &Query_for_list_of_variables},
 	{"VIEW", NULL, NULL, &Query_for_list_of_views},
 	{NULL}						/* end of list */
 };
@@ -1668,7 +1678,8 @@ psql_completion(const char *text, int start, int end)
 		"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
 		"COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE",
 		"DELETE FROM", "DISCARD", "DO", "DROP", "END", "EXECUTE", "EXPLAIN",
-		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LISTEN", "LOAD", "LOCK",
+		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LET",
+		"LISTEN", "LOAD", "LOCK",
 		"MERGE", "MOVE", "NOTIFY", "PREPARE",
 		"REASSIGN", "REFRESH MATERIALIZED VIEW", "REINDEX", "RELEASE",
 		"RESET", "REVOKE", "ROLLBACK",
@@ -1688,7 +1699,7 @@ psql_completion(const char *text, int start, int end)
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\dP", "\\dPi", "\\dPt",
 		"\\drds", "\\dRs", "\\dRp", "\\ds",
-		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy",
+		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy", "\\dV",
 		"\\echo", "\\edit", "\\ef", "\\elif", "\\else", "\\encoding",
 		"\\endif", "\\errverbose", "\\ev",
 		"\\f",
@@ -2129,6 +2140,9 @@ psql_completion(const char *text, int start, int end)
 										  "ALL");
 	else if (Matches("ALTER", "SYSTEM", "SET", MatchAny))
 		COMPLETE_WITH("TO");
+	/* ALTER VARIABLE <name> */
+	else if (Matches("ALTER", "VARIABLE", MatchAny))
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 	/* ALTER VIEW <name> */
 	else if (Matches("ALTER", "VIEW", MatchAny))
 		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME",
@@ -2644,7 +2658,7 @@ psql_completion(const char *text, int start, int end)
 					  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE", "SERVER",
 					  "STATISTICS", "SUBSCRIPTION", "TABLE",
 					  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
-					  "TRIGGER", "TYPE", "VIEW");
+					  "TRIGGER", "TYPE", "VARIABLE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
@@ -3082,7 +3096,7 @@ psql_completion(const char *text, int start, int end)
 /* CREATE TABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
 	else if (TailMatches("CREATE", "TEMP|TEMPORARY"))
-		COMPLETE_WITH("SEQUENCE", "TABLE", "VIEW");
+		COMPLETE_WITH("IMMUTABLE VARIABLE", "SEQUENCE", "TABLE", "VIEW", "VARIABLE");
 	/* Complete "CREATE UNLOGGED" with TABLE or MATVIEW */
 	else if (TailMatches("CREATE", "UNLOGGED"))
 		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW");
@@ -3389,6 +3403,17 @@ psql_completion(const char *text, int start, int end)
 		else if (TailMatches("=", MatchAnyExcept("*)")))
 			COMPLETE_WITH(",", ")");
 	}
+/* CREATE VARIABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
+	/* Complete CREATE VARIABLE <name> with AS */
+	else if (TailMatches("IMMUTABLE"))
+		COMPLETE_WITH("VARIABLE");
+	else if (TailMatches("CREATE", "VARIABLE", MatchAny) ||
+			 TailMatches("TEMP|TEMPORARY", "VARIABLE", MatchAny) ||
+			 TailMatches("IMMUTABLE", "VARIABLE", MatchAny))
+		COMPLETE_WITH("AS");
+	else if (TailMatches("VARIABLE", MatchAny, "AS"))
+		/* Complete CREATE VARIABLE <name> with AS types */
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
 
 /* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete CREATE [ OR REPLACE ] VIEW <name> with AS */
@@ -3504,7 +3529,7 @@ psql_completion(const char *text, int start, int end)
 
 /* DISCARD */
 	else if (Matches("DISCARD"))
-		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP");
+		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP", "VARIABLES");
 
 /* DO */
 	else if (Matches("DO"))
@@ -3631,6 +3656,12 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE", MatchAny))
 		COMPLETE_WITH("CASCADE", "RESTRICT");
 
+	/* DROP VARIABLE */
+	else if (Matches("DROP", "VARIABLE"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	else if (Matches("DROP", "VARIABLE", MatchAny))
+		COMPLETE_WITH("CASCADE", "RESTRICT");
+
 /* EXECUTE */
 	else if (Matches("EXECUTE"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
@@ -3747,7 +3778,8 @@ psql_completion(const char *text, int start, int end)
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
 			COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
 						  "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
-						  "EXECUTE", "USAGE", "ALL");
+						  "EXECUTE", "USAGE", "ALL",
+						  "READ", "WRITE");
 		else
 			COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
 									 "GRANT",
@@ -3765,6 +3797,8 @@ psql_completion(const char *text, int start, int end)
 									 "USAGE",
 									 "SET",
 									 "ALTER SYSTEM",
+									 "READ",
+									 "WRITE",
 									 "ALL");
 	}
 
@@ -3806,7 +3840,7 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("GRANT|REVOKE", MatchAny) ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny))
 	{
-		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|ALL"))
+		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|READ|WRITE|ALL"))
 			COMPLETE_WITH("ON");
 		else if (TailMatches("GRANT", MatchAny))
 			COMPLETE_WITH("TO");
@@ -3829,7 +3863,7 @@ psql_completion(const char *text, int start, int end)
 		 * objects supported.
 		 */
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
-			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS");
+			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS", "VARIABLES");
 		else
 			COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_grantables,
 											"ALL FUNCTIONS IN SCHEMA",
@@ -3851,7 +3885,8 @@ psql_completion(const char *text, int start, int end)
 											"SEQUENCE",
 											"TABLE",
 											"TABLESPACE",
-											"TYPE");
+											"TYPE",
+											"VARIABLE");
 	}
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "ALL"))
@@ -3859,7 +3894,8 @@ psql_completion(const char *text, int start, int end)
 					  "PROCEDURES IN SCHEMA",
 					  "ROUTINES IN SCHEMA",
 					  "SEQUENCES IN SCHEMA",
-					  "TABLES IN SCHEMA");
+					  "TABLES IN SCHEMA",
+					  "VARIABLES IN SCHEMA");
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "FOREIGN"))
 		COMPLETE_WITH("DATA WRAPPER", "SERVER");
@@ -3895,6 +3931,8 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
 		else if (TailMatches("TYPE"))
 			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
+		else if (TailMatches("VARIABLE"))
+			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 		else if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny))
 			COMPLETE_WITH("TO");
 		else
@@ -4137,7 +4175,7 @@ psql_completion(const char *text, int start, int end)
 
 /* PREPARE xx AS */
 	else if (Matches("PREPARE", MatchAny, "AS"))
-		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM");
+		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM", "LET");
 
 /*
  * PREPARE TRANSACTION is missing on purpose. It's intended for transaction
@@ -4425,6 +4463,14 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("UPDATE", MatchAny, "SET", MatchAnyExcept("*=")))
 		COMPLETE_WITH("=");
 
+/* LET --- can be inside EXPLAIN, PREPARE etc */
+	/* If prev. word is LET suggest a list of variables */
+	else if (TailMatches("LET"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	/* Complete LET <variable> with "=" */
+	else if (TailMatches("LET", MatchAny))
+		COMPLETE_WITH("=");
+
 /* USER MAPPING */
 	else if (Matches("ALTER|CREATE|DROP", "USER", "MAPPING"))
 		COMPLETE_WITH("FOR");
@@ -4591,6 +4637,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	else if (TailMatchesCS("\\dv*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views);
+	else if (TailMatchesCS("\\dV*"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 	else if (TailMatchesCS("\\dx*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_extensions);
 	else if (TailMatchesCS("\\dX*"))
-- 
2.37.0


--w2in66fnadvggvsb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename="v20220916-0009-possibility-to-dump-session-variables-by-p.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v20220922 08/13] enhancing psql for session variables
@ 2022-04-04 20:40  [email protected] <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: [email protected] @ 2022-04-04 20:40 UTC (permalink / raw)

\dV and tab complete for session variables related commands
---
 src/bin/psql/command.c      |  3 ++
 src/bin/psql/describe.c     | 96 +++++++++++++++++++++++++++++++++++++
 src/bin/psql/describe.h     |  3 ++
 src/bin/psql/help.c         |  1 +
 src/bin/psql/tab-complete.c | 71 ++++++++++++++++++++++-----
 5 files changed, 162 insertions(+), 12 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a141146e70..83738b10f3 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -944,6 +944,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 						break;
 				}
 				break;
+			case 'V':			/* Variables */
+				success = listVariables(pattern, show_verbose);
+				break;
 			case 'x':			/* Extensions */
 				if (show_verbose)
 					success = listExtensionContents(pattern);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index c645d66418..a958853c6d 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -5065,6 +5065,102 @@ error_return:
 	return false;
 }
 
+/*
+ * \dV
+ *
+ * listVariables()
+ */
+bool
+listVariables(const char *pattern, bool verbose)
+{
+	PQExpBufferData buf;
+	PGresult   *res;
+	printQueryOpt myopt = pset.popt;
+	static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false};
+
+	initPQExpBuffer(&buf);
+
+	printfPQExpBuffer(&buf,
+					  "SELECT n.nspname as \"%s\",\n"
+					  "  v.varname as \"%s\",\n"
+					  "  pg_catalog.format_type(v.vartype, v.vartypmod) as \"%s\",\n"
+					  "  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
+					  "   WHERE c.oid = v.varcollation AND bt.oid = v.vartype AND v.varcollation <> bt.typcollation) as \"%s\",\n"
+					  "  NOT v.varisnotnull as \"%s\",\n"
+					  "  NOT v.varisimmutable as \"%s\",\n"
+					  "  pg_catalog.pg_get_expr(v.vardefexpr, 0) as \"%s\",\n"
+					  "  pg_catalog.pg_get_userbyid(v.varowner) as \"%s\",\n"
+					  "  CASE v.vareoxaction\n"
+					  "    WHEN 'd' THEN 'ON COMMIT DROP'\n"
+					  "    WHEN 'r' THEN 'ON TRANSACTION END RESET' END as \"%s\"\n",
+					  gettext_noop("Schema"),
+					  gettext_noop("Name"),
+					  gettext_noop("Type"),
+					  gettext_noop("Collation"),
+					  gettext_noop("Nullable"),
+					  gettext_noop("Mutable"),
+					  gettext_noop("Default"),
+					  gettext_noop("Owner"),
+					  gettext_noop("Transactional end action"));
+
+	if (verbose)
+	{
+		appendPQExpBufferStr(&buf, ",\n  ");
+		printACLColumn(&buf, "v.varacl");
+		appendPQExpBuffer(&buf,
+						  ",\n  pg_catalog.obj_description(v.oid, 'pg_variable') AS \"%s\"",
+						  gettext_noop("Description"));
+	}
+
+	appendPQExpBufferStr(&buf,
+						 "\nFROM pg_catalog.pg_variable v"
+						 "\n     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = v.varnamespace");
+
+	appendPQExpBufferStr(&buf, "\nWHERE true\n");
+	if (!pattern)
+		appendPQExpBufferStr(&buf, "      AND n.nspname <> 'pg_catalog'\n"
+							 "      AND n.nspname <> 'information_schema'\n");
+
+	if (!validateSQLNamePattern(&buf, pattern, true, false,
+								"n.nspname", "v.varname", NULL,
+								"pg_catalog.pg_variable_is_visible(v.oid)",
+								NULL, 3))
+		return false;
+
+	appendPQExpBufferStr(&buf, "ORDER BY 1,2;");
+
+	res = PSQLexec(buf.data);
+	termPQExpBuffer(&buf);
+	if (!res)
+		return false;
+
+	/*
+	 * Most functions in this file are content to print an empty table when
+	 * there are no matching objects.  We intentionally deviate from that
+	 * here, but only in !quiet mode, for historical reasons.
+	 */
+	if (PQntuples(res) == 0 && !pset.quiet)
+	{
+		if (pattern)
+			pg_log_error("Did not find any session variable named \"%s\".",
+						 pattern);
+		else
+			pg_log_error("Did not find any session variables.");
+	}
+	else
+	{
+		myopt.nullPrint = NULL;
+		myopt.title = _("List of variables");
+		myopt.translate_header = true;
+		myopt.translate_columns = translate_columns;
+		myopt.n_translate_columns = lengthof(translate_columns);
+
+		printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
+	}
+
+	PQclear(res);
+	return true;
+}
 
 /*
  * \dFp
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index bd051e09cb..4baa699fcd 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -146,4 +146,7 @@ extern bool listOpFamilyFunctions(const char *access_method_pattern,
 /* \dl or \lo_list */
 extern bool listLargeObjects(bool verbose);
 
+/* \dV */
+extern bool listVariables(const char *pattern, bool varbose);
+
 #endif							/* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index f8ce1a0706..dcdfb20418 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -286,6 +286,7 @@ slashUsage(unsigned short int pager)
 	HELP0("  \\dT[S+] [PATTERN]      list data types\n");
 	HELP0("  \\du[S+] [PATTERN]      list roles\n");
 	HELP0("  \\dv[S+] [PATTERN]      list views\n");
+	HELP0("  \\dV     [PATTERN]      list variables\n");
 	HELP0("  \\dx[+]  [PATTERN]      list extensions\n");
 	HELP0("  \\dX     [PATTERN]      list extended statistics\n");
 	HELP0("  \\dy[+]  [PATTERN]      list event triggers\n");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 820f47d23a..0567ad16e2 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -962,6 +962,13 @@ static const SchemaQuery Query_for_trigger_of_table = {
 	.refnamespace = "c1.relnamespace",
 };
 
+static const SchemaQuery Query_for_list_of_variables = {
+	.min_server_version = 150000,
+	.catname = "pg_catalog.pg_variable v",
+	.viscondition = "pg_catalog.pg_variable_is_visible(v.oid)",
+	.namespace = "v.varnamespace",
+	.result = "v.varname",
+};
 
 /*
  * Queries to get lists of names of various kinds of things, possibly
@@ -1219,6 +1226,8 @@ static const pgsql_thing_t words_after_create[] = {
 	{"FOREIGN TABLE", NULL, NULL, NULL},
 	{"FUNCTION", NULL, NULL, Query_for_list_of_functions},
 	{"GROUP", Query_for_list_of_roles},
+	{"IMMUTABLE VARIABLE", NULL, NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE IMMUTABLE
+																					 * VARIABLE ... */
 	{"INDEX", NULL, NULL, &Query_for_list_of_indexes},
 	{"LANGUAGE", Query_for_list_of_languages},
 	{"LARGE OBJECT", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
@@ -1257,6 +1266,7 @@ static const pgsql_thing_t words_after_create[] = {
 																			 * TABLE ... */
 	{"USER", Query_for_list_of_roles, NULL, NULL, Keywords_for_user_thing},
 	{"USER MAPPING FOR", NULL, NULL, NULL},
+	{"VARIABLE", NULL, NULL, &Query_for_list_of_variables},
 	{"VIEW", NULL, NULL, &Query_for_list_of_views},
 	{NULL}						/* end of list */
 };
@@ -1668,8 +1678,8 @@ psql_completion(const char *text, int start, int end)
 		"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
 		"COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE",
 		"DELETE FROM", "DISCARD", "DO", "DROP", "END", "EXECUTE", "EXPLAIN",
-		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LISTEN", "LOAD", "LOCK",
-		"MERGE INTO", "MOVE", "NOTIFY", "PREPARE",
+		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LET",
+		"LISTEN", "LOAD", "LOCK", "MERGE INTO", "MOVE", "NOTIFY", "PREPARE",
 		"REASSIGN", "REFRESH MATERIALIZED VIEW", "REINDEX", "RELEASE",
 		"RESET", "REVOKE", "ROLLBACK",
 		"SAVEPOINT", "SECURITY LABEL", "SELECT", "SET", "SHOW", "START",
@@ -1688,7 +1698,7 @@ psql_completion(const char *text, int start, int end)
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\dP", "\\dPi", "\\dPt",
 		"\\drds", "\\dRs", "\\dRp", "\\ds",
-		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy",
+		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy", "\\dV",
 		"\\echo", "\\edit", "\\ef", "\\elif", "\\else", "\\encoding",
 		"\\endif", "\\errverbose", "\\ev",
 		"\\f",
@@ -2129,6 +2139,9 @@ psql_completion(const char *text, int start, int end)
 										  "ALL");
 	else if (Matches("ALTER", "SYSTEM", "SET", MatchAny))
 		COMPLETE_WITH("TO");
+	/* ALTER VARIABLE <name> */
+	else if (Matches("ALTER", "VARIABLE", MatchAny))
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 	/* ALTER VIEW <name> */
 	else if (Matches("ALTER", "VIEW", MatchAny))
 		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME",
@@ -2644,7 +2657,7 @@ psql_completion(const char *text, int start, int end)
 					  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE", "SERVER",
 					  "STATISTICS", "SUBSCRIPTION", "TABLE",
 					  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
-					  "TRIGGER", "TYPE", "VIEW");
+					  "TRIGGER", "TYPE", "VARIABLE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
@@ -3082,7 +3095,7 @@ psql_completion(const char *text, int start, int end)
 /* CREATE TABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
 	else if (TailMatches("CREATE", "TEMP|TEMPORARY"))
-		COMPLETE_WITH("SEQUENCE", "TABLE", "VIEW");
+		COMPLETE_WITH("IMMUTABLE VARIABLE", "SEQUENCE", "TABLE", "VIEW", "VARIABLE");
 	/* Complete "CREATE UNLOGGED" with TABLE or MATVIEW */
 	else if (TailMatches("CREATE", "UNLOGGED"))
 		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW");
@@ -3389,6 +3402,17 @@ psql_completion(const char *text, int start, int end)
 		else if (TailMatches("=", MatchAnyExcept("*)")))
 			COMPLETE_WITH(",", ")");
 	}
+/* CREATE VARIABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
+	/* Complete CREATE VARIABLE <name> with AS */
+	else if (TailMatches("IMMUTABLE"))
+		COMPLETE_WITH("VARIABLE");
+	else if (TailMatches("CREATE", "VARIABLE", MatchAny) ||
+			 TailMatches("TEMP|TEMPORARY", "VARIABLE", MatchAny) ||
+			 TailMatches("IMMUTABLE", "VARIABLE", MatchAny))
+		COMPLETE_WITH("AS");
+	else if (TailMatches("VARIABLE", MatchAny, "AS"))
+		/* Complete CREATE VARIABLE <name> with AS types */
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
 
 /* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete CREATE [ OR REPLACE ] VIEW <name> with AS */
@@ -3504,7 +3528,7 @@ psql_completion(const char *text, int start, int end)
 
 /* DISCARD */
 	else if (Matches("DISCARD"))
-		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP");
+		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP", "VARIABLES");
 
 /* DO */
 	else if (Matches("DO"))
@@ -3631,6 +3655,12 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE", MatchAny))
 		COMPLETE_WITH("CASCADE", "RESTRICT");
 
+	/* DROP VARIABLE */
+	else if (Matches("DROP", "VARIABLE"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	else if (Matches("DROP", "VARIABLE", MatchAny))
+		COMPLETE_WITH("CASCADE", "RESTRICT");
+
 /* EXECUTE */
 	else if (Matches("EXECUTE"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
@@ -3747,7 +3777,8 @@ psql_completion(const char *text, int start, int end)
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
 			COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
 						  "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
-						  "EXECUTE", "USAGE", "ALL");
+						  "EXECUTE", "USAGE", "ALL",
+						  "READ", "WRITE");
 		else
 			COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
 									 "GRANT",
@@ -3765,6 +3796,8 @@ psql_completion(const char *text, int start, int end)
 									 "USAGE",
 									 "SET",
 									 "ALTER SYSTEM",
+									 "READ",
+									 "WRITE",
 									 "ALL");
 	}
 
@@ -3806,7 +3839,7 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("GRANT|REVOKE", MatchAny) ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny))
 	{
-		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|ALL"))
+		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|READ|WRITE|ALL"))
 			COMPLETE_WITH("ON");
 		else if (TailMatches("GRANT", MatchAny))
 			COMPLETE_WITH("TO");
@@ -3829,7 +3862,7 @@ psql_completion(const char *text, int start, int end)
 		 * objects supported.
 		 */
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
-			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS");
+			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS", "VARIABLES");
 		else
 			COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_grantables,
 											"ALL FUNCTIONS IN SCHEMA",
@@ -3851,7 +3884,8 @@ psql_completion(const char *text, int start, int end)
 											"SEQUENCE",
 											"TABLE",
 											"TABLESPACE",
-											"TYPE");
+											"TYPE",
+											"VARIABLE");
 	}
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "ALL"))
@@ -3859,7 +3893,8 @@ psql_completion(const char *text, int start, int end)
 					  "PROCEDURES IN SCHEMA",
 					  "ROUTINES IN SCHEMA",
 					  "SEQUENCES IN SCHEMA",
-					  "TABLES IN SCHEMA");
+					  "TABLES IN SCHEMA",
+					  "VARIABLES IN SCHEMA");
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "FOREIGN"))
 		COMPLETE_WITH("DATA WRAPPER", "SERVER");
@@ -3895,6 +3930,8 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
 		else if (TailMatches("TYPE"))
 			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
+		else if (TailMatches("VARIABLE"))
+			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 		else if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny))
 			COMPLETE_WITH("TO");
 		else
@@ -4169,7 +4206,7 @@ psql_completion(const char *text, int start, int end)
 
 /* PREPARE xx AS */
 	else if (Matches("PREPARE", MatchAny, "AS"))
-		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM");
+		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM", "LET");
 
 /*
  * PREPARE TRANSACTION is missing on purpose. It's intended for transaction
@@ -4457,6 +4494,14 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("UPDATE", MatchAny, "SET", MatchAnyExcept("*=")))
 		COMPLETE_WITH("=");
 
+/* LET --- can be inside EXPLAIN, PREPARE etc */
+	/* If prev. word is LET suggest a list of variables */
+	else if (TailMatches("LET"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	/* Complete LET <variable> with "=" */
+	else if (TailMatches("LET", MatchAny))
+		COMPLETE_WITH("=");
+
 /* USER MAPPING */
 	else if (Matches("ALTER|CREATE|DROP", "USER", "MAPPING"))
 		COMPLETE_WITH("FOR");
@@ -4623,6 +4668,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	else if (TailMatchesCS("\\dv*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views);
+	else if (TailMatchesCS("\\dV*"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 	else if (TailMatchesCS("\\dx*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_extensions);
 	else if (TailMatchesCS("\\dX*"))
-- 
2.37.0


--z3ntqfnlkpftg4xg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename="v20220922-0009-possibility-to-dump-session-variables-by-p.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH 06/11] enhancing psql for session variables
@ 2022-04-04 20:40  [email protected] <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: [email protected] @ 2022-04-04 20:40 UTC (permalink / raw)

\dV and tab complete for session variables related commands
---
 src/bin/psql/command.c      |  3 ++
 src/bin/psql/describe.c     | 96 +++++++++++++++++++++++++++++++++++++
 src/bin/psql/describe.h     |  3 ++
 src/bin/psql/help.c         |  1 +
 src/bin/psql/tab-complete.c | 70 ++++++++++++++++++++++-----
 5 files changed, 162 insertions(+), 11 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a141146e70..83738b10f3 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -944,6 +944,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 						break;
 				}
 				break;
+			case 'V':			/* Variables */
+				success = listVariables(pattern, show_verbose);
+				break;
 			case 'x':			/* Extensions */
 				if (show_verbose)
 					success = listExtensionContents(pattern);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index c645d66418..a958853c6d 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -5065,6 +5065,102 @@ error_return:
 	return false;
 }
 
+/*
+ * \dV
+ *
+ * listVariables()
+ */
+bool
+listVariables(const char *pattern, bool verbose)
+{
+	PQExpBufferData buf;
+	PGresult   *res;
+	printQueryOpt myopt = pset.popt;
+	static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false};
+
+	initPQExpBuffer(&buf);
+
+	printfPQExpBuffer(&buf,
+					  "SELECT n.nspname as \"%s\",\n"
+					  "  v.varname as \"%s\",\n"
+					  "  pg_catalog.format_type(v.vartype, v.vartypmod) as \"%s\",\n"
+					  "  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
+					  "   WHERE c.oid = v.varcollation AND bt.oid = v.vartype AND v.varcollation <> bt.typcollation) as \"%s\",\n"
+					  "  NOT v.varisnotnull as \"%s\",\n"
+					  "  NOT v.varisimmutable as \"%s\",\n"
+					  "  pg_catalog.pg_get_expr(v.vardefexpr, 0) as \"%s\",\n"
+					  "  pg_catalog.pg_get_userbyid(v.varowner) as \"%s\",\n"
+					  "  CASE v.vareoxaction\n"
+					  "    WHEN 'd' THEN 'ON COMMIT DROP'\n"
+					  "    WHEN 'r' THEN 'ON TRANSACTION END RESET' END as \"%s\"\n",
+					  gettext_noop("Schema"),
+					  gettext_noop("Name"),
+					  gettext_noop("Type"),
+					  gettext_noop("Collation"),
+					  gettext_noop("Nullable"),
+					  gettext_noop("Mutable"),
+					  gettext_noop("Default"),
+					  gettext_noop("Owner"),
+					  gettext_noop("Transactional end action"));
+
+	if (verbose)
+	{
+		appendPQExpBufferStr(&buf, ",\n  ");
+		printACLColumn(&buf, "v.varacl");
+		appendPQExpBuffer(&buf,
+						  ",\n  pg_catalog.obj_description(v.oid, 'pg_variable') AS \"%s\"",
+						  gettext_noop("Description"));
+	}
+
+	appendPQExpBufferStr(&buf,
+						 "\nFROM pg_catalog.pg_variable v"
+						 "\n     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = v.varnamespace");
+
+	appendPQExpBufferStr(&buf, "\nWHERE true\n");
+	if (!pattern)
+		appendPQExpBufferStr(&buf, "      AND n.nspname <> 'pg_catalog'\n"
+							 "      AND n.nspname <> 'information_schema'\n");
+
+	if (!validateSQLNamePattern(&buf, pattern, true, false,
+								"n.nspname", "v.varname", NULL,
+								"pg_catalog.pg_variable_is_visible(v.oid)",
+								NULL, 3))
+		return false;
+
+	appendPQExpBufferStr(&buf, "ORDER BY 1,2;");
+
+	res = PSQLexec(buf.data);
+	termPQExpBuffer(&buf);
+	if (!res)
+		return false;
+
+	/*
+	 * Most functions in this file are content to print an empty table when
+	 * there are no matching objects.  We intentionally deviate from that
+	 * here, but only in !quiet mode, for historical reasons.
+	 */
+	if (PQntuples(res) == 0 && !pset.quiet)
+	{
+		if (pattern)
+			pg_log_error("Did not find any session variable named \"%s\".",
+						 pattern);
+		else
+			pg_log_error("Did not find any session variables.");
+	}
+	else
+	{
+		myopt.nullPrint = NULL;
+		myopt.title = _("List of variables");
+		myopt.translate_header = true;
+		myopt.translate_columns = translate_columns;
+		myopt.n_translate_columns = lengthof(translate_columns);
+
+		printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
+	}
+
+	PQclear(res);
+	return true;
+}
 
 /*
  * \dFp
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 7872c71f58..6960c738bd 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -146,4 +146,7 @@ extern bool listOpFamilyFunctions(const char *access_method_pattern,
 /* \dl or \lo_list */
 extern bool listLargeObjects(bool verbose);
 
+/* \dV */
+extern bool listVariables(const char *pattern, bool varbose);
+
 #endif							/* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index f8ce1a0706..dcdfb20418 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -286,6 +286,7 @@ slashUsage(unsigned short int pager)
 	HELP0("  \\dT[S+] [PATTERN]      list data types\n");
 	HELP0("  \\du[S+] [PATTERN]      list roles\n");
 	HELP0("  \\dv[S+] [PATTERN]      list views\n");
+	HELP0("  \\dV     [PATTERN]      list variables\n");
 	HELP0("  \\dx[+]  [PATTERN]      list extensions\n");
 	HELP0("  \\dX     [PATTERN]      list extended statistics\n");
 	HELP0("  \\dy[+]  [PATTERN]      list event triggers\n");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 62a39779b9..2780c2239c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -962,6 +962,13 @@ static const SchemaQuery Query_for_trigger_of_table = {
 	.refnamespace = "c1.relnamespace",
 };
 
+static const SchemaQuery Query_for_list_of_variables = {
+	.min_server_version = 150000,
+	.catname = "pg_catalog.pg_variable v",
+	.viscondition = "pg_catalog.pg_variable_is_visible(v.oid)",
+	.namespace = "v.varnamespace",
+	.result = "v.varname",
+};
 
 /*
  * Queries to get lists of names of various kinds of things, possibly
@@ -1219,6 +1226,8 @@ static const pgsql_thing_t words_after_create[] = {
 	{"FOREIGN TABLE", NULL, NULL, NULL},
 	{"FUNCTION", NULL, NULL, Query_for_list_of_functions},
 	{"GROUP", Query_for_list_of_roles},
+	{"IMMUTABLE VARIABLE", NULL, NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER},	/* for CREATE
+																				 * IMMUTABLE VARIABLE ... */
 	{"INDEX", NULL, NULL, &Query_for_list_of_indexes},
 	{"LANGUAGE", Query_for_list_of_languages},
 	{"LARGE OBJECT", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
@@ -1257,6 +1266,7 @@ static const pgsql_thing_t words_after_create[] = {
 																			 * TABLE ... */
 	{"USER", Query_for_list_of_roles, NULL, NULL, Keywords_for_user_thing},
 	{"USER MAPPING FOR", NULL, NULL, NULL},
+	{"VARIABLE", NULL, NULL, &Query_for_list_of_variables},
 	{"VIEW", NULL, NULL, &Query_for_list_of_views},
 	{NULL}						/* end of list */
 };
@@ -1668,7 +1678,8 @@ psql_completion(const char *text, int start, int end)
 		"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
 		"COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE",
 		"DELETE FROM", "DISCARD", "DO", "DROP", "END", "EXECUTE", "EXPLAIN",
-		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LISTEN", "LOAD", "LOCK",
+		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LET",
+		"LISTEN", "LOAD", "LOCK",
 		"MERGE", "MOVE", "NOTIFY", "PREPARE",
 		"REASSIGN", "REFRESH MATERIALIZED VIEW", "REINDEX", "RELEASE",
 		"RESET", "REVOKE", "ROLLBACK",
@@ -1688,7 +1699,7 @@ psql_completion(const char *text, int start, int end)
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\dP", "\\dPi", "\\dPt",
 		"\\drds", "\\dRs", "\\dRp", "\\ds",
-		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy",
+		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy", "\\dV",
 		"\\echo", "\\edit", "\\ef", "\\elif", "\\else", "\\encoding",
 		"\\endif", "\\errverbose", "\\ev",
 		"\\f",
@@ -2129,6 +2140,9 @@ psql_completion(const char *text, int start, int end)
 										  "ALL");
 	else if (Matches("ALTER", "SYSTEM", "SET", MatchAny))
 		COMPLETE_WITH("TO");
+	/* ALTER VARIABLE <name> */
+	else if (Matches("ALTER", "VARIABLE", MatchAny))
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 	/* ALTER VIEW <name> */
 	else if (Matches("ALTER", "VIEW", MatchAny))
 		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME",
@@ -2635,7 +2649,7 @@ psql_completion(const char *text, int start, int end)
 					  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE", "SERVER",
 					  "STATISTICS", "SUBSCRIPTION", "TABLE",
 					  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
-					  "TRIGGER", "TYPE", "VIEW");
+					  "TRIGGER", "TYPE", "VARIABLE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
@@ -3073,7 +3087,7 @@ psql_completion(const char *text, int start, int end)
 /* CREATE TABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
 	else if (TailMatches("CREATE", "TEMP|TEMPORARY"))
-		COMPLETE_WITH("SEQUENCE", "TABLE", "VIEW");
+		COMPLETE_WITH("IMMUTABLE VARIABLE", "SEQUENCE", "TABLE", "VIEW", "VARIABLE");
 	/* Complete "CREATE UNLOGGED" with TABLE or MATVIEW */
 	else if (TailMatches("CREATE", "UNLOGGED"))
 		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW");
@@ -3380,6 +3394,17 @@ psql_completion(const char *text, int start, int end)
 		else if (TailMatches("=", MatchAnyExcept("*)")))
 			COMPLETE_WITH(",", ")");
 	}
+/* CREATE VARIABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
+	/* Complete CREATE VARIABLE <name> with AS */
+	else if (TailMatches("IMMUTABLE"))
+		COMPLETE_WITH("VARIABLE");
+	else if (TailMatches("CREATE", "VARIABLE", MatchAny) ||
+			 TailMatches("TEMP|TEMPORARY", "VARIABLE", MatchAny) ||
+			 TailMatches("IMMUTABLE", "VARIABLE", MatchAny))
+			COMPLETE_WITH("AS");
+	else if (TailMatches("VARIABLE", MatchAny, "AS"))
+			/* Complete CREATE VARIABLE <name> with AS types */
+			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
 
 /* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete CREATE [ OR REPLACE ] VIEW <name> with AS */
@@ -3495,7 +3520,7 @@ psql_completion(const char *text, int start, int end)
 
 /* DISCARD */
 	else if (Matches("DISCARD"))
-		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP");
+		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP", "VARIABLES");
 
 /* DO */
 	else if (Matches("DO"))
@@ -3622,6 +3647,12 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE", MatchAny))
 		COMPLETE_WITH("CASCADE", "RESTRICT");
 
+	/* DROP VARIABLE */
+	else if (Matches("DROP", "VARIABLE"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	else if (Matches("DROP", "VARIABLE", MatchAny))
+		COMPLETE_WITH("CASCADE", "RESTRICT");
+
 /* EXECUTE */
 	else if (Matches("EXECUTE"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
@@ -3738,7 +3769,8 @@ psql_completion(const char *text, int start, int end)
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
 			COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
 						  "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
-						  "EXECUTE", "USAGE", "ALL");
+						  "EXECUTE", "USAGE", "ALL",
+						  "READ", "WRITE");
 		else
 			COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
 									 "GRANT",
@@ -3756,6 +3788,8 @@ psql_completion(const char *text, int start, int end)
 									 "USAGE",
 									 "SET",
 									 "ALTER SYSTEM",
+									 "READ",
+									 "WRITE",
 									 "ALL");
 	}
 
@@ -3797,7 +3831,7 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("GRANT|REVOKE", MatchAny) ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny))
 	{
-		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|ALL"))
+		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|READ|WRITE|ALL"))
 			COMPLETE_WITH("ON");
 		else if (TailMatches("GRANT", MatchAny))
 			COMPLETE_WITH("TO");
@@ -3820,7 +3854,7 @@ psql_completion(const char *text, int start, int end)
 		 * objects supported.
 		 */
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
-			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS");
+			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS", "VARIABLES");
 		else
 			COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_grantables,
 											"ALL FUNCTIONS IN SCHEMA",
@@ -3842,7 +3876,8 @@ psql_completion(const char *text, int start, int end)
 											"SEQUENCE",
 											"TABLE",
 											"TABLESPACE",
-											"TYPE");
+											"TYPE",
+											"VARIABLE");
 	}
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "ALL"))
@@ -3850,7 +3885,8 @@ psql_completion(const char *text, int start, int end)
 					  "PROCEDURES IN SCHEMA",
 					  "ROUTINES IN SCHEMA",
 					  "SEQUENCES IN SCHEMA",
-					  "TABLES IN SCHEMA");
+					  "TABLES IN SCHEMA",
+					  "VARIABLES IN SCHEMA");
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "FOREIGN"))
 		COMPLETE_WITH("DATA WRAPPER", "SERVER");
@@ -3886,6 +3922,8 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
 		else if (TailMatches("TYPE"))
 			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
+		else if (TailMatches("VARIABLE"))
+			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 		else if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny))
 			COMPLETE_WITH("TO");
 		else
@@ -4128,7 +4166,7 @@ psql_completion(const char *text, int start, int end)
 
 /* PREPARE xx AS */
 	else if (Matches("PREPARE", MatchAny, "AS"))
-		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM");
+		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM", "LET");
 
 /*
  * PREPARE TRANSACTION is missing on purpose. It's intended for transaction
@@ -4416,6 +4454,14 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("UPDATE", MatchAny, "SET", MatchAnyExcept("*=")))
 		COMPLETE_WITH("=");
 
+/* LET --- can be inside EXPLAIN, PREPARE etc */
+	/* If prev. word is LET suggest a list of variables */
+	else if (TailMatches("LET"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	/* Complete LET <variable> with "=" */
+	else if (TailMatches("LET", MatchAny))
+		COMPLETE_WITH("=");
+
 /* USER MAPPING */
 	else if (Matches("ALTER|CREATE|DROP", "USER", "MAPPING"))
 		COMPLETE_WITH("FOR");
@@ -4582,6 +4628,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	else if (TailMatchesCS("\\dv*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views);
+	else if (TailMatchesCS("\\dV*"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 	else if (TailMatchesCS("\\dx*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_extensions);
 	else if (TailMatchesCS("\\dX*"))
-- 
2.37.2


--gcms4zhgklsgym3k
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename*0=v20220906-1-0007-possibility-to-dump-session-variables-by-pg_;
	filename*1="dump.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v20220916 08/13] enhancing psql for session variables
@ 2022-04-04 20:40  [email protected] <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: [email protected] @ 2022-04-04 20:40 UTC (permalink / raw)

\dV and tab complete for session variables related commands
---
 src/bin/psql/command.c      |  3 ++
 src/bin/psql/describe.c     | 96 +++++++++++++++++++++++++++++++++++++
 src/bin/psql/describe.h     |  3 ++
 src/bin/psql/help.c         |  1 +
 src/bin/psql/tab-complete.c | 70 ++++++++++++++++++++++-----
 5 files changed, 162 insertions(+), 11 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a141146e70..83738b10f3 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -944,6 +944,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 						break;
 				}
 				break;
+			case 'V':			/* Variables */
+				success = listVariables(pattern, show_verbose);
+				break;
 			case 'x':			/* Extensions */
 				if (show_verbose)
 					success = listExtensionContents(pattern);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index c645d66418..a958853c6d 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -5065,6 +5065,102 @@ error_return:
 	return false;
 }
 
+/*
+ * \dV
+ *
+ * listVariables()
+ */
+bool
+listVariables(const char *pattern, bool verbose)
+{
+	PQExpBufferData buf;
+	PGresult   *res;
+	printQueryOpt myopt = pset.popt;
+	static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false};
+
+	initPQExpBuffer(&buf);
+
+	printfPQExpBuffer(&buf,
+					  "SELECT n.nspname as \"%s\",\n"
+					  "  v.varname as \"%s\",\n"
+					  "  pg_catalog.format_type(v.vartype, v.vartypmod) as \"%s\",\n"
+					  "  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
+					  "   WHERE c.oid = v.varcollation AND bt.oid = v.vartype AND v.varcollation <> bt.typcollation) as \"%s\",\n"
+					  "  NOT v.varisnotnull as \"%s\",\n"
+					  "  NOT v.varisimmutable as \"%s\",\n"
+					  "  pg_catalog.pg_get_expr(v.vardefexpr, 0) as \"%s\",\n"
+					  "  pg_catalog.pg_get_userbyid(v.varowner) as \"%s\",\n"
+					  "  CASE v.vareoxaction\n"
+					  "    WHEN 'd' THEN 'ON COMMIT DROP'\n"
+					  "    WHEN 'r' THEN 'ON TRANSACTION END RESET' END as \"%s\"\n",
+					  gettext_noop("Schema"),
+					  gettext_noop("Name"),
+					  gettext_noop("Type"),
+					  gettext_noop("Collation"),
+					  gettext_noop("Nullable"),
+					  gettext_noop("Mutable"),
+					  gettext_noop("Default"),
+					  gettext_noop("Owner"),
+					  gettext_noop("Transactional end action"));
+
+	if (verbose)
+	{
+		appendPQExpBufferStr(&buf, ",\n  ");
+		printACLColumn(&buf, "v.varacl");
+		appendPQExpBuffer(&buf,
+						  ",\n  pg_catalog.obj_description(v.oid, 'pg_variable') AS \"%s\"",
+						  gettext_noop("Description"));
+	}
+
+	appendPQExpBufferStr(&buf,
+						 "\nFROM pg_catalog.pg_variable v"
+						 "\n     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = v.varnamespace");
+
+	appendPQExpBufferStr(&buf, "\nWHERE true\n");
+	if (!pattern)
+		appendPQExpBufferStr(&buf, "      AND n.nspname <> 'pg_catalog'\n"
+							 "      AND n.nspname <> 'information_schema'\n");
+
+	if (!validateSQLNamePattern(&buf, pattern, true, false,
+								"n.nspname", "v.varname", NULL,
+								"pg_catalog.pg_variable_is_visible(v.oid)",
+								NULL, 3))
+		return false;
+
+	appendPQExpBufferStr(&buf, "ORDER BY 1,2;");
+
+	res = PSQLexec(buf.data);
+	termPQExpBuffer(&buf);
+	if (!res)
+		return false;
+
+	/*
+	 * Most functions in this file are content to print an empty table when
+	 * there are no matching objects.  We intentionally deviate from that
+	 * here, but only in !quiet mode, for historical reasons.
+	 */
+	if (PQntuples(res) == 0 && !pset.quiet)
+	{
+		if (pattern)
+			pg_log_error("Did not find any session variable named \"%s\".",
+						 pattern);
+		else
+			pg_log_error("Did not find any session variables.");
+	}
+	else
+	{
+		myopt.nullPrint = NULL;
+		myopt.title = _("List of variables");
+		myopt.translate_header = true;
+		myopt.translate_columns = translate_columns;
+		myopt.n_translate_columns = lengthof(translate_columns);
+
+		printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
+	}
+
+	PQclear(res);
+	return true;
+}
 
 /*
  * \dFp
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 7872c71f58..6960c738bd 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -146,4 +146,7 @@ extern bool listOpFamilyFunctions(const char *access_method_pattern,
 /* \dl or \lo_list */
 extern bool listLargeObjects(bool verbose);
 
+/* \dV */
+extern bool listVariables(const char *pattern, bool varbose);
+
 #endif							/* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index f8ce1a0706..dcdfb20418 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -286,6 +286,7 @@ slashUsage(unsigned short int pager)
 	HELP0("  \\dT[S+] [PATTERN]      list data types\n");
 	HELP0("  \\du[S+] [PATTERN]      list roles\n");
 	HELP0("  \\dv[S+] [PATTERN]      list views\n");
+	HELP0("  \\dV     [PATTERN]      list variables\n");
 	HELP0("  \\dx[+]  [PATTERN]      list extensions\n");
 	HELP0("  \\dX     [PATTERN]      list extended statistics\n");
 	HELP0("  \\dy[+]  [PATTERN]      list event triggers\n");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index f3465adb85..519c863202 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -962,6 +962,13 @@ static const SchemaQuery Query_for_trigger_of_table = {
 	.refnamespace = "c1.relnamespace",
 };
 
+static const SchemaQuery Query_for_list_of_variables = {
+	.min_server_version = 150000,
+	.catname = "pg_catalog.pg_variable v",
+	.viscondition = "pg_catalog.pg_variable_is_visible(v.oid)",
+	.namespace = "v.varnamespace",
+	.result = "v.varname",
+};
 
 /*
  * Queries to get lists of names of various kinds of things, possibly
@@ -1219,6 +1226,8 @@ static const pgsql_thing_t words_after_create[] = {
 	{"FOREIGN TABLE", NULL, NULL, NULL},
 	{"FUNCTION", NULL, NULL, Query_for_list_of_functions},
 	{"GROUP", Query_for_list_of_roles},
+	{"IMMUTABLE VARIABLE", NULL, NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE IMMUTABLE
+																					 * VARIABLE ... */
 	{"INDEX", NULL, NULL, &Query_for_list_of_indexes},
 	{"LANGUAGE", Query_for_list_of_languages},
 	{"LARGE OBJECT", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
@@ -1257,6 +1266,7 @@ static const pgsql_thing_t words_after_create[] = {
 																			 * TABLE ... */
 	{"USER", Query_for_list_of_roles, NULL, NULL, Keywords_for_user_thing},
 	{"USER MAPPING FOR", NULL, NULL, NULL},
+	{"VARIABLE", NULL, NULL, &Query_for_list_of_variables},
 	{"VIEW", NULL, NULL, &Query_for_list_of_views},
 	{NULL}						/* end of list */
 };
@@ -1668,7 +1678,8 @@ psql_completion(const char *text, int start, int end)
 		"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
 		"COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE",
 		"DELETE FROM", "DISCARD", "DO", "DROP", "END", "EXECUTE", "EXPLAIN",
-		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LISTEN", "LOAD", "LOCK",
+		"FETCH", "GRANT", "IMPORT FOREIGN SCHEMA", "INSERT INTO", "LET",
+		"LISTEN", "LOAD", "LOCK",
 		"MERGE", "MOVE", "NOTIFY", "PREPARE",
 		"REASSIGN", "REFRESH MATERIALIZED VIEW", "REINDEX", "RELEASE",
 		"RESET", "REVOKE", "ROLLBACK",
@@ -1688,7 +1699,7 @@ psql_completion(const char *text, int start, int end)
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\dP", "\\dPi", "\\dPt",
 		"\\drds", "\\dRs", "\\dRp", "\\ds",
-		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy",
+		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dX", "\\dy", "\\dV",
 		"\\echo", "\\edit", "\\ef", "\\elif", "\\else", "\\encoding",
 		"\\endif", "\\errverbose", "\\ev",
 		"\\f",
@@ -2129,6 +2140,9 @@ psql_completion(const char *text, int start, int end)
 										  "ALL");
 	else if (Matches("ALTER", "SYSTEM", "SET", MatchAny))
 		COMPLETE_WITH("TO");
+	/* ALTER VARIABLE <name> */
+	else if (Matches("ALTER", "VARIABLE", MatchAny))
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 	/* ALTER VIEW <name> */
 	else if (Matches("ALTER", "VIEW", MatchAny))
 		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME",
@@ -2644,7 +2658,7 @@ psql_completion(const char *text, int start, int end)
 					  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE", "SERVER",
 					  "STATISTICS", "SUBSCRIPTION", "TABLE",
 					  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
-					  "TRIGGER", "TYPE", "VIEW");
+					  "TRIGGER", "TYPE", "VARIABLE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
@@ -3082,7 +3096,7 @@ psql_completion(const char *text, int start, int end)
 /* CREATE TABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
 	else if (TailMatches("CREATE", "TEMP|TEMPORARY"))
-		COMPLETE_WITH("SEQUENCE", "TABLE", "VIEW");
+		COMPLETE_WITH("IMMUTABLE VARIABLE", "SEQUENCE", "TABLE", "VIEW", "VARIABLE");
 	/* Complete "CREATE UNLOGGED" with TABLE or MATVIEW */
 	else if (TailMatches("CREATE", "UNLOGGED"))
 		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW");
@@ -3389,6 +3403,17 @@ psql_completion(const char *text, int start, int end)
 		else if (TailMatches("=", MatchAnyExcept("*)")))
 			COMPLETE_WITH(",", ")");
 	}
+/* CREATE VARIABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
+	/* Complete CREATE VARIABLE <name> with AS */
+	else if (TailMatches("IMMUTABLE"))
+		COMPLETE_WITH("VARIABLE");
+	else if (TailMatches("CREATE", "VARIABLE", MatchAny) ||
+			 TailMatches("TEMP|TEMPORARY", "VARIABLE", MatchAny) ||
+			 TailMatches("IMMUTABLE", "VARIABLE", MatchAny))
+		COMPLETE_WITH("AS");
+	else if (TailMatches("VARIABLE", MatchAny, "AS"))
+		/* Complete CREATE VARIABLE <name> with AS types */
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
 
 /* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete CREATE [ OR REPLACE ] VIEW <name> with AS */
@@ -3504,7 +3529,7 @@ psql_completion(const char *text, int start, int end)
 
 /* DISCARD */
 	else if (Matches("DISCARD"))
-		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP");
+		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP", "VARIABLES");
 
 /* DO */
 	else if (Matches("DO"))
@@ -3631,6 +3656,12 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE", MatchAny))
 		COMPLETE_WITH("CASCADE", "RESTRICT");
 
+	/* DROP VARIABLE */
+	else if (Matches("DROP", "VARIABLE"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	else if (Matches("DROP", "VARIABLE", MatchAny))
+		COMPLETE_WITH("CASCADE", "RESTRICT");
+
 /* EXECUTE */
 	else if (Matches("EXECUTE"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
@@ -3747,7 +3778,8 @@ psql_completion(const char *text, int start, int end)
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
 			COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
 						  "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
-						  "EXECUTE", "USAGE", "ALL");
+						  "EXECUTE", "USAGE", "ALL",
+						  "READ", "WRITE");
 		else
 			COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
 									 "GRANT",
@@ -3765,6 +3797,8 @@ psql_completion(const char *text, int start, int end)
 									 "USAGE",
 									 "SET",
 									 "ALTER SYSTEM",
+									 "READ",
+									 "WRITE",
 									 "ALL");
 	}
 
@@ -3806,7 +3840,7 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("GRANT|REVOKE", MatchAny) ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny))
 	{
-		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|ALL"))
+		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|READ|WRITE|ALL"))
 			COMPLETE_WITH("ON");
 		else if (TailMatches("GRANT", MatchAny))
 			COMPLETE_WITH("TO");
@@ -3829,7 +3863,7 @@ psql_completion(const char *text, int start, int end)
 		 * objects supported.
 		 */
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
-			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS");
+			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS", "VARIABLES");
 		else
 			COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_grantables,
 											"ALL FUNCTIONS IN SCHEMA",
@@ -3851,7 +3885,8 @@ psql_completion(const char *text, int start, int end)
 											"SEQUENCE",
 											"TABLE",
 											"TABLESPACE",
-											"TYPE");
+											"TYPE",
+											"VARIABLE");
 	}
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "ALL"))
@@ -3859,7 +3894,8 @@ psql_completion(const char *text, int start, int end)
 					  "PROCEDURES IN SCHEMA",
 					  "ROUTINES IN SCHEMA",
 					  "SEQUENCES IN SCHEMA",
-					  "TABLES IN SCHEMA");
+					  "TABLES IN SCHEMA",
+					  "VARIABLES IN SCHEMA");
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN") ||
 			 TailMatches("REVOKE", "GRANT", "OPTION", "FOR", MatchAny, "ON", "FOREIGN"))
 		COMPLETE_WITH("DATA WRAPPER", "SERVER");
@@ -3895,6 +3931,8 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
 		else if (TailMatches("TYPE"))
 			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
+		else if (TailMatches("VARIABLE"))
+			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 		else if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny))
 			COMPLETE_WITH("TO");
 		else
@@ -4137,7 +4175,7 @@ psql_completion(const char *text, int start, int end)
 
 /* PREPARE xx AS */
 	else if (Matches("PREPARE", MatchAny, "AS"))
-		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM");
+		COMPLETE_WITH("SELECT", "UPDATE", "INSERT INTO", "DELETE FROM", "LET");
 
 /*
  * PREPARE TRANSACTION is missing on purpose. It's intended for transaction
@@ -4425,6 +4463,14 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("UPDATE", MatchAny, "SET", MatchAnyExcept("*=")))
 		COMPLETE_WITH("=");
 
+/* LET --- can be inside EXPLAIN, PREPARE etc */
+	/* If prev. word is LET suggest a list of variables */
+	else if (TailMatches("LET"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
+	/* Complete LET <variable> with "=" */
+	else if (TailMatches("LET", MatchAny))
+		COMPLETE_WITH("=");
+
 /* USER MAPPING */
 	else if (Matches("ALTER|CREATE|DROP", "USER", "MAPPING"))
 		COMPLETE_WITH("FOR");
@@ -4591,6 +4637,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	else if (TailMatchesCS("\\dv*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views);
+	else if (TailMatchesCS("\\dV*"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_variables);
 	else if (TailMatchesCS("\\dx*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_extensions);
 	else if (TailMatchesCS("\\dX*"))
-- 
2.37.0


--w2in66fnadvggvsb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename="v20220916-0009-possibility-to-dump-session-variables-by-p.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1202cb07c07..55926ec15e0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8d81dcdc2f6..dfedf5c2851 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8603,9 +8600,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--GzYugJnip6WHHvTk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v7-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5b22fdc8e08..6bf78edf535 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--iWwo79nqhOvOs5kf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  8 +++-----
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fd00d6c3515..f2edf61f9a0 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index b00ede45e41..d39852c8323 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3984,9 +3984,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8577,9 +8574,10 @@
   prorettype => 'text', proargtypes => 'oid int4',
   prosrc => 'pg_get_viewdef_wrap' },
 { oid => '2507',
-  descr => 'index description (full create statement or single expression) with pretty-print option',
+  descr => 'index description',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.53.0


--AcCatzXgbvyipyEy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v8.1-0004-Handle-pg_get_constraintdef-default-args-in-sys.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index c7adfad0e05..f7b9d26089a 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7d576834d5c..92e2f987074 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2d1aa50dac6..62b997a1653 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3955,9 +3955,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8501,7 +8498,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.51.2


--IRGsBYp1UN8d6WrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 57b4adc0e2a..bb5863212cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 9b87b9eda5f..56f68cee830 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--3/nz5wg6+DYwHsLU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use CREATE OR REPLACE FUNCTION to handle
the optional column and pretty argument.
---
 src/backend/catalog/system_functions.sql |  7 +++++++
 src/backend/utils/adt/ruleutils.c        | 20 --------------------
 src/include/catalog/pg_proc.dat          |  5 +----
 src/include/catalog/pg_retired.dat       |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 4ddbf194fa8..72f5fdc06f9 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -678,6 +678,13 @@ LANGUAGE INTERNAL
 PARALLEL RESTRICTED
 AS 'pg_get_viewdef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_indexdef(view oid, "column" int DEFAULT 0, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL SAFE
+AS 'pg_get_indexdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 29557f3c9d2..d8b8d7b4d38 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1114,26 +1114,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 531d0dea7db..fee5efca41e 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3964,9 +3964,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8517,7 +8514,7 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index d5d51ddb3e8..768ce980a1d 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -19,6 +19,7 @@
 
 { oid => '1573', proname => 'pg_get_ruledef' },
 { oid => '1640', proname => 'pg_get_viewdef' },
-{ oid => '1641', proname => 'pg_get_viewdef' }
+{ oid => '1641', proname => 'pg_get_viewdef' },
+{ oid => '1643', proname => 'pg_get_indexdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0005-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 328f994547e..b40158d30bb 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1115,26 +1115,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 166ae4b5645..7e45cbcb93d 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3965,9 +3965,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8528,7 +8525,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.43.0


--eEEy3EHc57lA8spa
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql
@ 2025-12-09 18:02  Mark Wong <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Mark Wong @ 2025-12-09 18:02 UTC (permalink / raw)

Modernize pg_get_indexdef to use proargdefaults to handle the optional
column and pretty argument.
---
 src/backend/utils/adt/ruleutils.c | 20 --------------------
 src/include/catalog/pg_proc.dat   |  6 ++----
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 24c59510672..77a7b0ca769 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1125,26 +1125,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
  */
 Datum
 pg_get_indexdef(PG_FUNCTION_ARGS)
-{
-	Oid			indexrelid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_indexdef_worker(indexrelid, 0, NULL,
-								 false, false,
-								 false, false,
-								 prettyFlags, true);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-Datum
-pg_get_indexdef_ext(PG_FUNCTION_ARGS)
 {
 	Oid			indexrelid = PG_GETARG_OID(0);
 	int32		colno = PG_GETARG_INT32(1);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c1b945cdae5..1dc0d01cc85 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3978,9 +3978,6 @@
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
-{ oid => '1643', descr => 'index description',
-  proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid', prosrc => 'pg_get_indexdef' },
 { oid => '3415', descr => 'extended statistics object description',
   proname => 'pg_get_statisticsobjdef', provolatile => 's',
   prorettype => 'text', proargtypes => 'oid',
@@ -8592,7 +8589,8 @@
 { oid => '2507',
   descr => 'index description (full create statement or single expression) with pretty-print option',
   proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
-  proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef_ext' },
+  proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
+  proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
 { oid => '2508', descr => 'constraint description with pretty-print option',
   proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
   proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
-- 
2.52.0


--m23X5uHFNxthGTU3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v5-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch



^ permalink  raw  reply  [nested|flat] 214+ messages in thread

* [PATCH v26a 1/2] instrumentation: Show additional TSC clock source info in pg_test_timing
@ 2026-04-08 17:11  Lukas Fittl <[email protected]>
  0 siblings, 0 replies; 214+ messages in thread

From: Lukas Fittl @ 2026-04-08 17:11 UTC (permalink / raw)

In some cases its needed to understand whether TSC frequency data was
sourced from CPUID, and which of the registers. This shows this debug
information at the end of pg_test_timing, through use of a new
pg_timing_tsc_clock_source_info function, replacing the previous
pg_tsc_calibrate_frequency export that was only needed for debug info.

Author: Lukas Fittl <[email protected]>
Suggested-by: Andres Freund <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/jr4hk2sxhqcfpb67ftz5g4vw33nm67cgf7go3wwmqsafu5aclq%405m67...
---
 src/include/port/pg_cpu.h               |  2 +-
 src/include/portability/instr_time.h    | 11 ++++++-
 src/common/instr_time.c                 | 44 +++++++++++++++++++++++--
 src/port/pg_cpu_x86.c                   | 23 +++++++++++--
 src/bin/pg_test_timing/pg_test_timing.c | 12 ++++---
 src/tools/pgindent/typedefs.list        |  1 +
 6 files changed, 81 insertions(+), 12 deletions(-)

diff --git a/src/include/port/pg_cpu.h b/src/include/port/pg_cpu.h
index a5d42f1b68d..db4cd62f7ef 100644
--- a/src/include/port/pg_cpu.h
+++ b/src/include/port/pg_cpu.h
@@ -56,7 +56,7 @@ x86_feature_available(X86FeatureId feature)
 	return X86Features[feature];
 }
 
-extern uint32 x86_tsc_frequency_khz(void);
+extern uint32 x86_tsc_frequency_khz(char *source, size_t source_len);
 
 #endif							/* defined(USE_SSE2) || defined(__i386__) */
 
diff --git a/src/include/portability/instr_time.h b/src/include/portability/instr_time.h
index 92558e234ac..4917728afc3 100644
--- a/src/include/portability/instr_time.h
+++ b/src/include/portability/instr_time.h
@@ -165,7 +165,16 @@ extern PGDLLIMPORT int32 timing_tsc_frequency_khz;
 
 extern void pg_initialize_timing_tsc(void);
 
-extern uint32 pg_tsc_calibrate_frequency(void);
+typedef struct TscClockSourceInfo
+{
+	int32		frequency_khz;	/* from CPUID or calibration */
+	int32		calibrated_frequency_khz;	/* from calibration loop, 0 if did
+											 * not converge, -1 if not yet run */
+	char		frequency_source[128];	/* describes how frequency was
+										 * determined */
+} TscClockSourceInfo;
+
+extern const TscClockSourceInfo *pg_timing_tsc_clock_source_info(void);
 
 #endif							/* PG_INSTR_TSC_CLOCK */
 
diff --git a/src/common/instr_time.c b/src/common/instr_time.c
index fc6e1852c30..2523d6a0df6 100644
--- a/src/common/instr_time.c
+++ b/src/common/instr_time.c
@@ -70,6 +70,8 @@ static void set_ticks_per_ns(void);
 static void set_ticks_per_ns_system(void);
 
 #if PG_INSTR_TSC_CLOCK
+static TscClockSourceInfo tsc_info = {.calibrated_frequency_khz = -1};
+
 static bool tsc_use_by_default(void);
 static void set_ticks_per_ns_for_tsc(void);
 #endif
@@ -166,6 +168,7 @@ set_ticks_per_ns_system(void)
 #if PG_INSTR_TSC_CLOCK
 
 static void tsc_detect_frequency(void);
+static uint32 pg_tsc_calibrate_frequency(void);
 
 /*
  * Initialize the TSC clock source by determining its usability and frequency.
@@ -202,21 +205,36 @@ static void
 tsc_detect_frequency(void)
 {
 	timing_tsc_frequency_khz = 0;
+	tsc_info.frequency_khz = 0;
+	tsc_info.frequency_source[0] = '\0';
 
 	/* We require RDTSCP support and an invariant TSC, bail if not available */
 	if (!x86_feature_available(PG_RDTSCP) || !x86_feature_available(PG_TSC_INVARIANT))
 		return;
 
 	/* Determine speed at which the TSC advances */
-	timing_tsc_frequency_khz = x86_tsc_frequency_khz();
+	timing_tsc_frequency_khz = x86_tsc_frequency_khz(tsc_info.frequency_source,
+													 sizeof(tsc_info.frequency_source));
 	if (timing_tsc_frequency_khz > 0)
+	{
+		tsc_info.frequency_khz = timing_tsc_frequency_khz;
 		return;
+	}
 
 	/*
 	 * CPUID did not give us the TSC frequency. We can instead measure the
 	 * frequency by comparing ticks against walltime in a calibration loop.
 	 */
-	timing_tsc_frequency_khz = pg_tsc_calibrate_frequency();
+	if (tsc_info.calibrated_frequency_khz < 0)
+		tsc_info.calibrated_frequency_khz = pg_tsc_calibrate_frequency();
+
+	timing_tsc_frequency_khz = tsc_info.calibrated_frequency_khz;
+	if (timing_tsc_frequency_khz > 0)
+	{
+		strlcpy(tsc_info.frequency_source, "x86, calibration",
+				sizeof(tsc_info.frequency_source));
+		tsc_info.frequency_khz = timing_tsc_frequency_khz;
+	}
 }
 
 /*
@@ -282,7 +300,7 @@ tsc_use_by_default(void)
 #define TSC_CALIBRATION_ITERATIONS	1000000
 #define TSC_CALIBRATION_SKIPS		100
 #define TSC_CALIBRATION_STABLE_CYCLES	10
-uint32
+static uint32
 pg_tsc_calibrate_frequency(void)
 {
 	instr_time	initial_wall;
@@ -369,4 +387,24 @@ pg_tsc_calibrate_frequency(void)
 	return (uint32) freq_khz;
 }
 
+/*
+ * Returns TSC clock source information for diagnostic purposes.
+ *
+ * On first call, runs the TSC calibration loop (if not already done during
+ * frequency detection) which may take up to TSC_CALIBRATION_MAX_NS.
+ * Subsequent calls return cached results.
+ *
+ * Note: This won't return the right info in EXEC_BACKEND builds if this were
+ * used in the backend (which it currently is not), as tsc_info is not copied
+ * using read_backend_variables - only the TSC frequency is.
+ */
+const TscClockSourceInfo *
+pg_timing_tsc_clock_source_info(void)
+{
+	if (tsc_info.calibrated_frequency_khz < 0)
+		tsc_info.calibrated_frequency_khz = pg_tsc_calibrate_frequency();
+
+	return &tsc_info;
+}
+
 #endif							/* PG_INSTR_TSC_CLOCK */
diff --git a/src/port/pg_cpu_x86.c b/src/port/pg_cpu_x86.c
index 150b4a1d574..c097807fc7f 100644
--- a/src/port/pg_cpu_x86.c
+++ b/src/port/pg_cpu_x86.c
@@ -13,7 +13,11 @@
  *-------------------------------------------------------------------------
  */
 
-#include "c.h"
+#ifndef FRONTEND
+#include "postgres.h"
+#else
+#include "postgres_fe.h"
+#endif
 
 #if defined(USE_SSE2) || defined(__i386__)
 
@@ -161,10 +165,13 @@ static uint32 x86_hypervisor_tsc_frequency_khz(void);
  * 0 indicates the frequency information was not accessible via CPUID.
  */
 uint32
-x86_tsc_frequency_khz(void)
+x86_tsc_frequency_khz(char *source, size_t source_len)
 {
 	unsigned int reg[4] = {0};
 
+	if (source)
+		strlcpy(source, "x86", source_len);
+
 	/*
 	 * If we're inside a virtual machine, try to fetch the TSC frequency from
 	 * the hypervisor, using a hypervisor specific method.
@@ -174,7 +181,11 @@ x86_tsc_frequency_khz(void)
 	 * to be wildly incorrect when virtualized.
 	 */
 	if (x86_feature_available(PG_HYPERVISOR))
+	{
+		if (source)
+			strlcat(source, ", hypervisor, cpuid 0x40000010", source_len);
 		return x86_hypervisor_tsc_frequency_khz();
+	}
 
 	/*
 	 * On modern Intel CPUs, the TSC is implemented by invariant timekeeping
@@ -207,6 +218,9 @@ x86_tsc_frequency_khz(void)
 		if (reg[EAX] == 0 || reg[EBX] == 0)
 			return 0;
 
+		if (source)
+			strlcat(source, ", cpuid 0x15", source_len);
+
 		return reg[ECX] / 1000 * reg[EBX] / reg[EAX];
 	}
 
@@ -217,7 +231,12 @@ x86_tsc_frequency_khz(void)
 	 */
 	pg_cpuid(0x16, reg);
 	if (reg[EAX] > 0)
+	{
+		if (source)
+			strlcat(source, ", cpuid 0x16", source_len);
+
 		return reg[EAX] * 1000;
+	}
 
 	return 0;
 }
diff --git a/src/bin/pg_test_timing/pg_test_timing.c b/src/bin/pg_test_timing/pg_test_timing.c
index 2afb0e6a410..ef5dd90c41f 100644
--- a/src/bin/pg_test_timing/pg_test_timing.c
+++ b/src/bin/pg_test_timing/pg_test_timing.c
@@ -184,7 +184,7 @@ static void
 test_tsc_timing(void)
 {
 	uint64		loop_count;
-	uint32		calibrated_freq;
+	const TscClockSourceInfo *info;
 
 	printf("\n");
 	loop_count = test_timing(test_duration, TIMING_CLOCK_SOURCE_TSC, false);
@@ -198,11 +198,13 @@ test_tsc_timing(void)
 		output(loop_count);
 		printf("\n");
 
-		printf(_("TSC frequency in use: %u kHz\n"), timing_tsc_frequency_khz);
+		info = pg_timing_tsc_clock_source_info();
+		printf(_("TSC frequency in use: %d kHz\n"), info->frequency_khz);
+		if (info->frequency_source[0] != '\0')
+			printf(_("TSC frequency source: %s\n"), info->frequency_source);
 
-		calibrated_freq = pg_tsc_calibrate_frequency();
-		if (calibrated_freq > 0)
-			printf(_("TSC frequency from calibration: %u kHz\n"), calibrated_freq);
+		if (info->calibrated_frequency_khz > 0)
+			printf(_("TSC frequency from calibration: %d kHz\n"), info->calibrated_frequency_khz);
 		else
 			printf(_("TSC calibration did not converge\n"));
 
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index ea95e7984bc..2137f1e0cfe 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -3090,6 +3090,7 @@ TParserStateActionItem
 TQueueDestReceiver
 TRGM
 TSAnyCacheEntry
+TscClockSourceInfo
 TSConfigCacheEntry
 TSConfigInfo
 TSDictInfo
-- 
2.53.0.1.gb2826b52eb


--5ynaw2hkmtmijn2o
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v26a-0002-fixup-instrumentation-Show-additional-TSC-clock.patch"



^ permalink  raw  reply  [nested|flat] 214+ messages in thread


end of thread, other threads:[~2026-04-08 17:11 UTC | newest]

Thread overview: 214+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 20:40 [PATCH 06/11] enhancing psql for session variables [email protected] <[email protected]>
2022-04-04 20:40 [PATCH v20220916 08/13] enhancing psql for session variables [email protected] <[email protected]>
2022-04-04 20:40 [PATCH 06/11] enhancing psql for session variables [email protected] <[email protected]>
2022-04-04 20:40 [PATCH v20220916 08/13] enhancing psql for session variables [email protected] <[email protected]>
2022-04-04 20:40 [PATCH v20220922 08/13] enhancing psql for session variables [email protected] <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v7 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v5 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v2 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v8.1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v1 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v3 4/7] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2025-12-09 18:02 [PATCH v4 3/6] Handle pg_get_indexdef default args in system_functions.sql Mark Wong <[email protected]>
2026-04-08 17:11 [PATCH v26a 1/2] instrumentation: Show additional TSC clock source info in pg_test_timing Lukas Fittl <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox