diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
new file mode 100644
index fd22612..4ec1aff
*** a/src/backend/commands/tablespace.c
--- b/src/backend/commands/tablespace.c
*************** CreateTableSpace(CreateTableSpaceStmt *s
*** 288,293 ****
--- 288,299 ----
  				 errmsg("tablespace location \"%s\" is too long",
  						location)));
  
+ 	/* Warn if the tablespace is in the data directory. */
+ 	if (path_is_prefix_of_path(DataDir, location))
+ 		ereport(WARNING,
+ 				(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ 				 errmsg("tablespace location should not be inside the data directory")));
+ 
  	/*
  	 * Disallow creation of tablespaces named "pg_xxx"; we reserve this
  	 * namespace for system purposes.
