aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2015-04-28 17:35:12 -0400
committerBruce Momjian <bruce@momjian.us>2015-04-28 17:35:12 -0400
commit33cb8ff6aa1159f0a359691ca563c98b85d3d723 (patch)
treed1649f59a3c5832d03176e7dfc396517d34341dc /src
parent290713e31a1ee04eed7877985a4c28a30fd0d1db (diff)
downloadpostgresql-33cb8ff6aa1159f0a359691ca563c98b85d3d723.tar.gz
postgresql-33cb8ff6aa1159f0a359691ca563c98b85d3d723.zip
Warn about tablespace creation in PGDATA
Also add warning to pg_upgrade Report by Josh Berkus
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/tablespace.c6
-rw-r--r--src/bin/pg_upgrade/check.c4
2 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index fd226125a93..4ec1affbfb1 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -288,6 +288,12 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
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.
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 647bf349f4d..6db223ab070 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -508,6 +508,10 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
canonicalize_path(old_tablespace_dir);
if (path_is_prefix_of_path(old_cluster_pgdata, old_tablespace_dir))
{
+ /* reproduce warning from CREATE TABLESPACE that is in the log */
+ pg_log(PG_WARNING,
+ "\nWARNING: user-defined tablespace locations should not be inside the data directory, e.g. %s\n", old_tablespace_dir);
+
/* Unlink file in case it is left over from a previous run. */
unlink(*deletion_script_file_name);
pg_free(*deletion_script_file_name);