From 38c34daaad05825d41027b8f5962658b3eee507a Mon Sep 17 00:00:00 2001
From: Jianghua Yang <yjhjstz@gmail.com>
Date: Tue, 1 Jul 2025 19:52:52 -0700
Subject: [PATCH] initdb: Treat empty -U argument as unset username

---
 src/bin/initdb/initdb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 62bbd08d9f6..2df15996271 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -3472,7 +3472,7 @@ main(int argc, char *argv[])
 	setup_bin_paths(argv[0]);
 
 	effective_user = get_id();
-	if (!username)
+	if (!username || username[0] == '\0')
 		username = effective_user;
 
 	if (strncmp(username, "pg_", 3) == 0)
-- 
2.39.5 (Apple Git-154)

