diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index f9c2620..6a89be1 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -606,23 +606,21 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid)
 		}
 	}
 
+	
 	/*
-	 * The creation of the version directory prevents more than one tablespace
-	 * in a single location.
+	 * Check the target directory is empty.
 	 */
+	if (!directory_is_empty(location))
+		ereport(ERROR,
+				(errcode(ERRCODE_OBJECT_IN_USE),
+				 errmsg("directory \"%s\" is not empty",
+						location)));
+
 	if (mkdir(location_with_version_dir, S_IRWXU) < 0)
-	{
-		if (errno == EEXIST)
-			ereport(ERROR,
-					(errcode(ERRCODE_OBJECT_IN_USE),
-					 errmsg("directory \"%s\" already in use as a tablespace",
-							location_with_version_dir)));
-		else
-			ereport(ERROR,
-					(errcode_for_file_access(),
-					 errmsg("could not create directory \"%s\": %m",
-							location_with_version_dir)));
-	}
+		ereport(ERROR,
+				(errcode_for_file_access(),
+				 errmsg("could not create directory \"%s\": %m",
+						location_with_version_dir)));
 
 	/*
 	 * In recovery, remove old symlink, in case it points to the wrong place.
