File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,12 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
288288 errmsg ("tablespace location \"%s\" is too long" ,
289289 location )));
290290
291+ /* Warn if the tablespace is in the data directory. */
292+ if (path_is_prefix_of_path (DataDir , location ))
293+ ereport (WARNING ,
294+ (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
295+ errmsg ("tablespace location should not be inside the data directory" )));
296+
291297 /*
292298 * Disallow creation of tablespaces named "pg_xxx"; we reserve this
293299 * namespace for system purposes.
Original file line number Diff line number Diff line change @@ -508,6 +508,10 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
508508 canonicalize_path (old_tablespace_dir );
509509 if (path_is_prefix_of_path (old_cluster_pgdata , old_tablespace_dir ))
510510 {
511+ /* reproduce warning from CREATE TABLESPACE that is in the log */
512+ pg_log (PG_WARNING ,
513+ "\nWARNING: user-defined tablespace locations should not be inside the data directory, e.g. %s\n" , old_tablespace_dir );
514+
511515 /* Unlink file in case it is left over from a previous run. */
512516 unlink (* deletion_script_file_name );
513517 pg_free (* deletion_script_file_name );
You can’t perform that action at this time.
0 commit comments