Hi!

I have noticed the novice users are stuck trying to create tablespace over a directory whose owner is not the system postgres user. They observed the message "could not set permissions on directory ...: permission denied".

I want to add patch that prints hint to set required owner for the tablespace directory if this is the cause of the problem (*errno == EPERM* after calling *chmod*).


--
Regards,
Maksim Milyutin

diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index f7e9160..a8733d4 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -585,10 +585,16 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid)
 					 InRecovery ? errhint("Create this directory for the tablespace before "
 										  "restarting the server.") : 0));
 		else
+		{
+			bool wrong_owner = (errno == EPERM);
+
 			ereport(ERROR,
 					(errcode_for_file_access(),
 					 errmsg("could not set permissions on directory \"%s\": %m",
-							location)));
+							location),
+					 wrong_owner ? errhint("Install the PostgreSQL system user as "
+										   "the owner of this directory.") : 0));
+		}
 	}
 
 	if (InRecovery)

Reply via email to