From fb7bd4514a18c4fa74f229ae3a28899a2c764127 Mon Sep 17 00:00:00 2001
From: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Date: Sat, 29 Mar 2025 23:51:31 +0530
Subject: [PATCH 1/1] Log about all the invalid database/role/user names then
 throw error during pg_upgrade --check

---
 src/bin/pg_upgrade/check.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 39e74ad48bb..167b1853c8e 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -2136,17 +2136,6 @@ check_database_user_role_names_in_old_cluser(ClusterInfo *cluster)
 
 	PQclear(res);
 
-	if (script)
-	{
-		PQfinish(conn_template1);
-		fclose(script);
-		pg_log(PG_REPORT, "fatal");
-		pg_fatal("All the database names should have only valid characters.  A newline or \n"
-				"carriage return character is not allowed in database name.  To fix this, \n"
-				"please rename database names with valid names. \n"
-				"    %s", output_path);
-	}
-
 	/* Now check for users and roles. */
 	/* Can't use pg_authid because only superusers can view it. */
 	res = executeQueryOrDie(conn_template1,
@@ -2175,10 +2164,10 @@ check_database_user_role_names_in_old_cluser(ClusterInfo *cluster)
 	{
 		fclose(script);
 		pg_log(PG_REPORT, "fatal");
-		pg_fatal("All the role/user names should have only valid characters.  A newline or \n"
-				"carriage return characters is not allowed in role/user name.  To fix this, \n"
-				"please rename role/user names with valid names. \n"
-				"    %s", output_path);
+		pg_fatal("All the database or role/user names should have only valid characters.  A newline or \n"
+				"carriage return characters is not allowed in database or role/user names.  To fix this, \n"
+				"please rename database or role/user names with valid names. \n"
+				"See details in: %s", output_path);
 	}
 	else
 		check_ok();
-- 
2.43.0

